package cn.xinfei.xdecision.datasource.mysql.dynamic;

import cn.xinfei.xdecision.common.dynamic.DataSourceType;
import cn.xinfei.xdecision.common.dynamic.DynamicDatasourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

@Slf4j
public class DynamicDatasource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        DataSourceType dataSourceType = DynamicDatasourceContextHolder.getDataSourceType();
//        log.info("get datasource dataSourceType={}",dataSourceType);
//        log.info("get ds {}",dataSourceType);
        return dataSourceType;
    }
}